package com.htw.rv.fast_scroller.follow_scroller_bar

/**
 * @author htw
 * createTime: 2022-04-25
 * desc: 封装FastScroller相关的监听
 */
class FastScrollerBuilder {

    private var mFastScrollerState: FastScrollerState = FastScrollerState.Hidden

    private var mFastScrollerStateChangeListener: FastScrollerStateChangeListener? = null
    private var mFastScrollerLocationChangeListener: FastScrollerLocationChangeListener? = null

    fun setFastScrollerStateChangeListener(listener: FastScrollerStateChangeListener?): FastScrollerBuilder {
        mFastScrollerStateChangeListener = listener
        return this
    }

    fun getFastScrollerStateChangeListener() = mFastScrollerStateChangeListener

    fun setFastScrollerLocationChangeListener(listener: FastScrollerLocationChangeListener?): FastScrollerBuilder {
        mFastScrollerLocationChangeListener = listener
        return this
    }

    fun getFastScrollerLocationChangeListener() = mFastScrollerLocationChangeListener

    fun setFastScrollerState(state: Int): FastScrollerBuilder {
        when(state) {
            FastScrollerState.Hidden.type -> {
                setFastScrollerState(FastScrollerState.Hidden)
            }
            FastScrollerState.Visible.type -> {
                setFastScrollerState(FastScrollerState.Visible)
            }
            FastScrollerState.Dragging.type -> {
                setFastScrollerState(FastScrollerState.Dragging)
            }
        }
        return this
    }

    private fun setFastScrollerState(fastScrollerState: FastScrollerState): FastScrollerBuilder {
        mFastScrollerState = fastScrollerState
        return this
    }

    fun getFastScrollerState() = mFastScrollerState

}